diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2025-12-19 15:00:28 +0100 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2025-12-19 15:00:28 +0100 |
| commit | eb7920efa3dd6889fe30249de1f0f0f121f1715f (patch) | |
| tree | 488161eaed099ff1658ec3e31ce8663ba87e9a96 /src/pages/posts/[...page].astro | |
| parent | bb6624513223093219b595109d96d50291cabc0d (diff) | |
Refactor post pagination to sort posts before extracting unique tags
Diffstat (limited to 'src/pages/posts/[...page].astro')
| -rw-r--r-- | src/pages/posts/[...page].astro | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/pages/posts/[...page].astro b/src/pages/posts/[...page].astro index e07bc29..acca040 100644 --- a/src/pages/posts/[...page].astro +++ b/src/pages/posts/[...page].astro @@ -12,8 +12,9 @@ export const getStaticPaths = (async ({ paginate }) => { const MAX_POSTS_PER_PAGE = 10; const MAX_TAGS = 7; const allPosts = await getAllPosts(); - const uniqueTags = getUniqueTags(allPosts).slice(0, MAX_TAGS); - return paginate(allPosts.sort(collectionDateSort), { + const sortedPosts = allPosts.sort(collectionDateSort); + const uniqueTags = getUniqueTags(sortedPosts).slice(0, MAX_TAGS); + return paginate(sortedPosts, { pageSize: MAX_POSTS_PER_PAGE, props: { uniqueTags }, }); |
